<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="white">
    <link rel="stylesheet" href="../dist/main.css">

</head>
<body>
<div id="list">
    <!--轮播图-->


    <!--信号源列表-->
    <div id="refreshContainer" class="mui-content mui-scroll-wrapper">
        <div class="mui-scroll">
            <div id="slider" class="mui-slider" style="position: relative">
                <!--<div class="search">-->
                    <!--<div style="width: 100%;height: 100%;position: relative;">-->
                        <!--<i class="mui-icon mui-icon-search"></i>-->
                    <!--</div>-->

                <!--</div>-->
                <div class="mui-slider-group mui-slider-loop">
                    <!-- 额外增加的一个节点(循环轮播：第一个节点是最后一张轮播) -->
                    <div class="mui-slider-item mui-slider-item-duplicate">
                        <a href="#">
                            <img src="../img/bannerIndex_3(750_320).png" alt="">

                        </a>
                    </div>
                    <!-- 第一张 -->
                    <div class="mui-slider-item">
                        <a href="#">
                            <img src="../img/bannerIndex_1(750_320).png" alt="">
                        </a>
                    </div>
                    <!-- 第二张 -->
                    <div class="mui-slider-item">
                        <a href="#">
                            <img src="../img/bannerIndex_2(750_320).png" alt="">

                        </a>
                    </div>
                    <!-- 第三张 -->
                    <div class="mui-slider-item">
                        <a href="#">
                            <img src="../img/bannerIndex_3(750_320).png" alt="">

                        </a>
                    </div>

                    <!-- 额外增加的一个节点(循环轮播：最后一个节点是第一张轮播) -->
                    <div class="mui-slider-item mui-slider-item-duplicate">
                        <a href="#">
                            <img src="../img/bannerIndex_1(750_320).png" alt="">
                        </a>
                    </div>
                </div>
                <div class="mui-slider-indicator">
                    <div class="mui-indicator mui-active"></div>
                    <div class="mui-indicator"></div>
                    <div class="mui-indicator"></div>
                </div>
            </div>
            <!--排序导航-->
            <div class="header">
                <div class="mui-content">
                    <div class="mui-row">
                        <div class="mui-col-sm-3 mui-col-xs-3" style="position: relative">
                            <div class="center" id="screenBtn">
                                <span >全部</span>
                                <i class="glyphicon glyphicon-triangle-bottom"></i>
                            </div>
                            <div id="menu-wrapper" class="menu-wrapper" style="display: none;position: absolute;top:1.1rem;right: 19px;z-index: 1;width: 2rem ">
                                <div id="menu" class="menu">
                                    <ul class="mui-table-view mui-table-view-inverted">
                                        <li class="mui-table-view-cell mui-active">
                                            <a href="javascript:;">全部</a>
                                        </li>
                                        <li class="mui-table-view-cell mowNo" >
                                            <a href="javascript:;">已跟随</a>
                                        </li>
                                        <li class="mui-table-view-cell mowNo" >
                                            <a href="javascript:;">未跟随</a>
                                        </li>
                                        <li class="mui-table-view-cell">
                                            <a href="javascript:;">收藏</a>
                                        </li>

                                    </ul>
                                </div>
                            </div>
                        </div>
                        <div class="mui-col-sm-3 mui-col-xs-3">
                            <div class="center sort" style="position: relative" id="profitBtn">
                                <span>累计收益</span>
                                <div class="biaoBox">
                                    <i class="glyphicon glyphicon-triangle-top"></i>
                                    <i class="glyphicon glyphicon-triangle-bottom"></i>
                                </div>

                            </div>
                        </div>
                        <div class="mui-col-sm-3 mui-col-xs-3">
                            <div class="center sort" style="position: relative" id="follow">
                                <span>跟单人数</span>
                                <div class="biaoBox">
                                    <i class="glyphicon glyphicon-triangle-top"></i>
                                    <i class="glyphicon glyphicon-triangle-bottom"></i>
                                </div>

                            </div>
                        </div>
                        <div class="mui-col-sm-3 mui-col-xs-3" id="blance">
                            <div class="center sort" style="position: relative">
                                <span>当前余额</span>
                                <div class="biaoBox">
                                    <i class="glyphicon glyphicon-triangle-top"></i>
                                    <i class="glyphicon glyphicon-triangle-bottom"></i>
                                </div>

                            </div>
                        </div>


                    </div>
                </div>
            </div>
            <!--筛选-->

            <!--数据列表-->
            <ul class="mui-table-view mui-table-view-chevron" id="mowList">


            </ul>
            <div id="noDatas" style="display: none" class="noDatas">
                <img src="../img/warnNoUsers(310_240).png" alt="">
                <p>暂无信号源</p>
                <div class="btns" style="display: none">
                    <button class="mui-btn mui-btn-warning mui-btn-outlined" id="bidingBtn">成为信号源</button>
                </div>
            </div>
        </div>
    </div>



</div>
<view></view>

</body>
</html>
<script src="../dist/main.js"></script>

<script>
    $("title").html(mt5Obj.title)
    bolBinding();
    /*轮播图*/
    var slider = mui("#slider");
    var postDatas={
        limit:10,
        offset:0,
    };
    var self="";


    slider.slider({
        interval: 3000
    });
    /*自定义筛选框*/
    mui("#refreshContainer").on('tap','#screenBtn',function(){

        $("#menu-wrapper").show();
        bolclick=true;
    })
    mui("#refreshContainer").on('tap','#mowList',function(){

        $("#menu-wrapper").hide();
        bolclick=false;


    })


    //筛选
    mui("#menu").on('tap','a',function(){
        postDatas={
            limit:10,
            offset:0,
        };
        var inner=$(this).html();
        $("#screenBtn span").html(inner);
        $("#menu-wrapper").hide();
        $(this).parent().addClass("mui-active");
        $(this).parent().siblings().removeClass("mui-active");
        if(inner=="全部"){

        }else if(inner=="已跟随"){
            postDatas.follow=0;


        }
        else if(inner=="未跟随"){
            postDatas.follow=1;

        }
        else if(inner=="收藏"){
            postDatas.collection=0;
        }
        $("#mowList .hasboder").remove();
        getDatas()

    })


    /*上下刷新配置*/
    refreshApp()
    //下拉刷新
    function  refrecha() {
        $("#mowList .hasboder").remove();

        postDatas.offset=0;
        self=this;
        getDatas("down")
    }
    //    上拉加载
    function loadMore() {
        var offset=postDatas.offset
        self=this
        postDatas.offset=postDatas.offset+=10;
        getDatas()
    }
    // 判断是否绑定mt5

    //获取数据
    function getDatas(down) {

        var str;
        var icon;
        var collection;
        var bolFollow;
        var profit;
        $.ajax({
            url:mt5Obj.allUrl+"mt/user/sourceMtList",
            data:postDatas,
            success:function (data) {

                noMore(down,data);
                if(data.rows){
                    if(data.rows.length == 0){
                        if (data.total==0){
                            $("#noDatas").show();
                            $("#noDatas .btns").hide();

                            if(!sessionStorage.getItem("bolBindingMT5")){
                                noBinding()
                            }
                        }


                    }else{
                        $("#noDatas").hide();
                        $("#noDatas .btns").hide();
                    }
                    for(x in data.rows){

                        if (data.rows[x].icon){
                            icon=data.rows[x].icon
                        }else {
                            icon="../img/signalHead(120_120).png"
                        }

                        if(data.rows[x].collection==0){

                            collection='<img src="../img/heartFull(40_40).png" alt="" login="'+data.rows[x].sourceLogin+'" type="1" class="getHeart">';
                        }else{
                            collection='<img src="../img/heartEmpty(40_40).png" alt="" class="getHeart" login="'+data.rows[x].sourceLogin+'" type="0">'
                        }

                        if(sessionStorage.getItem("type")=="1"){
                            if(data.rows[x].follow ==0){
                                bolFollow='<button class="hasGen genBtn" sourceLogin="'+data.rows[x].sourceLogin+'">更改设置</button>'
                            }else{
                                bolFollow='<button class="genBtn" sourceLogin="'+data.rows[x].sourceLogin+'">立即跟单</button>'

                            }
                        }else{
                            bolFollow="";
                        }
                        if(data.rows[x].profit){

                            if(data.rows[x].profit>=0){
                                profit= '<p class="green">$'+retrunZero(data.rows[x].profit)+'</p>'
                            }else {
                                profit= '<p class="red">-$'+retrunZero(data.rows[x].profit).toString().split("-")[1].toLocaleString()+'</p>'
                            }
                        }else{
                            profit= '<p class="green">$0</p>'
                        }



                        str=' <div class="mui-row hasboder">'+
                            '                        <div class="mui-col-sm-3 mui-col-xs-3" id="more"  mtLogin="'+data.rows[x].sourceLogin +'">'+
                            '                                 <div class="tx" style="background:url('+icon +' );background-size: cover"></div>'+
                            '                        </div>'+
                            '                        <div class="mui-col-sm-5 mui-col-xs-5">'+
                            '                            <div class="mui-row">'+
                            '                            <div class="mui-col-sm-6 mui-col-xs-6 left">'+
                            '                                <p>累计收益：</p>'+
                            '                            </div>'+
                            '                            <div class="mui-col-sm-6 mui-col-xs-6 right">'+
                            profit+
                            '                            </div>'+
                            '                            </div>'+
                            '                            <div class="mui-row">'+
                            '                                <div class="mui-col-sm-6 mui-col-xs-6 left">'+
                            '                                    <p>当前余额：</p>'+
                            '                                </div>'+
                            '                                <div class="mui-col-sm-6 mui-col-xs-6 right">'+
                            '                                    <p>$'+retrunZero(data.rows[x].balance)+'</p>'+
                            '                                </div>'+
                            '                            </div>'+
                            '                            <div class="mui-row">'+
                            '                                <div class="mui-col-sm-6 mui-col-xs-6 left">'+
                            '                                    <p>跟单人数：</p>'+
                            '                                </div>'+
                            '                                <div class="mui-col-sm-6 mui-col-xs-6 right">'+
                            '                                    <p>'+retrunZero(data.rows[x].followNumber)+'</p>'+
                            '                                </div>'+
                            '                            </div>'+
                            '                        </div>'+
                            '                        <div class="mui-col-sm-4 mui-col-xs-4 three">'+
                            '                            <p>'+data.rows[x].name+'</p>'+collection+

                            '                            <br>'+bolFollow
                        '                        </div>'+
                        '                    </div>';
                        $("#mowList").append(str)

                    }

                }
                mui('#refreshContainer').pullRefresh().endPulldownToRefresh();

            }
        })
    }
    // 点击收藏
    mui("body").on('tap','.getHeart',function(){
        var type=$(this).attr("type");
        var login=$(this).attr("login");

        $.ajax({
            url:mt5Obj.allUrl+"collection/collections",
            type:"post",
            data:{
                sourceLogin:login,
                type:type,
            },
            success:function (data) {
                $("#mowList .hasboder").remove();
                if(data.data){
                    if(type==0){
                        mui.toast("收藏成功");
                    }else{
                        mui.toast("取消收藏成功")
                    }


                }
                getDatas();
            }
        })


    })
    //排序
    mui("body").on('tap','.sort',function(){
        postDatas.offset=0;
        $("#mowList .hasboder").remove();
        var type;
        var inner=$(this).children("span").html();
        delete postDatas.balance;
        delete postDatas.followNumber;
        delete postDatas.profit;



        if(!$(this).children("span").hasClass("active")){
            $(this).children("span").addClass("active")
            $(this).children(".biaoBox").children("i").eq(0).addClass("active")

            $(this).parent().siblings().children(".sort").children("span").removeClass("active");
            $(this).parent().siblings().children(".sort").children(".biaoBox").children(".active").removeClass("active");
            type=0;
        }
        else {
            if( $(this).children(".biaoBox").children("i").eq(0).hasClass("active")){
                $(this).children(".biaoBox").children("i").eq(0).removeClass("active");
                $(this).children(".biaoBox").children("i").eq(1).addClass("active");
                type=1;
            }else{
                $(this).children(".biaoBox").children("i").eq(1).removeClass("active");
                $(this).children(".biaoBox").children("i").eq(0).addClass("active");
                type=0;
            }

        }

        if (inner=="累计收益"){
            postDatas.profit=type;
        }else if(inner=="跟单人数"){
            postDatas.followNumber=type;
        }else if(inner=="当前余额"){
            postDatas.balance=type;
        }
        getDatas();





    })

    //    点击跟单
    mui("body").on('tap','.genBtn',function(){
        sessionStorage.setItem("sourceLogin",$(this).attr("sourceLogin"));

        if(sessionStorage.getItem("bolBindingMT5")=="false"){
            noBinding()
        }else{
            if( $(this).hasClass("hasGen")) {
                goUrl("genSet","10")
            }else{
                goUrl("genSet","11")
            }
        }


    })
//    查看更多
    mui("body").on('tap','#more',function(){
        sessionStorage.setItem("sourceLogin",$(this).attr("mtLogin"))
        goUrl("more","1")


    })
    //    去绑定
    mui("body").on('tap','#bidingBtn',function(){
        bolBinding()
        if(sessionStorage.getItem("bolBindingMT5")=="1"){
            mui.alert("您有账号正在审核中，审核通过后可绑定新的MT5账号");
        }else{
            goBinding();

        }

    })
</script>




